import { createStore } from 'vuex'
import createPersistedState from 'vuex-persistedstate'

const store = createStore({
	state() {
		return {
			user: {
				login: false,
				username: '',
				password: '',
				nickname: '',
				avatar: '',
				email: '',
				phone: '',
				status: true,
				lastLoginTime: '',
				lastLoginIp: '',
				remark: ''
			}
		}
	},
	getters: {},
	mutations: {
		setUser(state, user) {
			state.user = user
		},
		setLogin(state, login) {
			state.user.login = login
		}
	},
	actions: {},
	plugins: [createPersistedState({ key: 'my_store' })]
})

export default store
